Skip to main content
Version: 1.3.0

Text to Image API Documentation

Text Validation Endpoint

  • Method: POST
  • Path: https://api.kadal.ai/text-to-image/api/v1/text_validation
  • Summary: Validates input text for suitability in image generation.

Description

This endpoint verifies that the provided text is well-formed and interpretable, ensuring it can be processed effectively to generate a corresponding image.

Request

  • Content-Type: multipart/form-data

Payload

ParameterDescriptionData TypeIs Optional
input_textText corresponding to which an image needs to be generatedStringNo

Response

Success (200 OK)

{
"status_code": 200,
"message": "SUCCESS::Text Validation generated successfully",
"input_text": "Your input text result will appear here"
}

Usage

import requests

url = "https://api.kadal.ai/text-to-image/api/v1/text_validation"
token = "your_token_here"

headers = {
"accept": "application/json",
"Authorization": f"Bearer {token}",
"Content-Type": "application/x-www-form-urlencoded",
}

data = {
"input_text": """A paper craft art depicting a girl giving her cat a gentle hug. Both sit amidst potted plants, with the cat purring contentedly while the girl smiles. The scene is adorned with handcrafted paper flowers and leaves."""
}

response = requests.post(url, headers=headers, data=data)

Text to Image Generation Endpoint

  • Method: POST
  • Path: https://api.kadal.ai/text-to-image/api/v1/text_to_image
  • Summary: Generates images from text with configurable count and aspect ratio.

Description

This endpoint generates images from input text using a selected AI model, with options to set the number of images and aspect ratio.

Request

  • Content-Type: multipart/form-data

Payload

ParameterDescriptionData TypeConstraints / Allowed ValuesOptional
user_model_selectionAI model used for generationStringMust be one of: dall-e-3No
input_textInput text promptStringNon-empty; max length: 300 charsNo
number_of_imagesNumber of images to generateStringRange: 1–3No
aspect_ratioAspect Ratio of imagesStringMust be one of: 1:1, 16:9, 9:16No

Response:

{
"status_code": 200,
"message": "SUCCESS::Text to Image generated successfully",
"images_created": {
"image_url_1": "Your image_url will appear here",
"image_url_2": "Your image_url will appear here",
"image_url_3": "Your image_url will appear here"
}
}

Usage

import requests

url = "https://api.kadal.ai/text-to-image/api/v1/text_to_image"
token = "your_token_here"

headers = {
"accept": "application/json",
"Authorization": f"Bearer {token}",
"Content-Type": "application/x-www-form-urlencoded",
}

data = {
"user_model_selection": "dall-e-3",
"input_text": """A paper craft art depicting a girl giving her cat a gentle hug. Both sit amidst potted plants, with the cat purring contentedly while the girl smiles. The scene is adorned with handcrafted paper flowers and leaves.""",
"number_of_images": "3",
"aspect_ratio": "1:1",
}

response = requests.post(url, headers=headers, data=data)